<?php defined('_JEXEC') or die('Restricted access'); ?>

<h2>Lista rankingowa</h2>

<?php 
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$user_id = $user->get('id');

if($user->guest) {
	?>
	<h3>Nie masz uprawnień do oglądania tej treści!</h3>
	<?php
}
else {

$query = "SELECT * FROM ".$db->nameQuote('#__putmovies_rating').", ".$db->nameQuote('#__users')." WHERE ".$db->nameQuote('#__putmovies_rating.user_id')." = ".$db->nameQuote('#__users.id')." ORDER BY ".$db->nameQuote('#__putmovies_rating.rmse')." ASC";
$db->setQuery($query);
$rows = $db->loadAssocList();

$lp_number = 1;

$grey_color = "dfdfdf";
$top_color = "7af685";

?>
<table style="width:100%;">
<tr style="background-color:#b5ddff; font-weight: bold;">
	<td>Miejsce</td>
	<td>RMSE</td>
	<td>Zespół</td>
	<td>Data wczytania</td>
</tr>
<?php 

foreach ($rows as &$row) {
	$row_color = "ffffff";
	
	if($lp_number % 2 == 1)
		$row_color = $grey_color;
	
	if($lp_number < 4)
		$row_color = $top_color;
	
	?>
	<tr style="background-color:#<?php echo $row_color;?>;">
		<td><?php echo $lp_number; $lp_number++;?></td>
		<td><?php echo $row["rmse"];?></td>
		<td><?php echo $row["name"];?></td>
		<td><?php echo $row["date"];?></td>
	</tr>
	<?php 
}

}
?>
</table>